package top.yqingyu.httpserver.controller;

import top.yqingyu.httpserver.annotation.QyController;
import top.yqingyu.httpserver.common.HttpMethod;
import top.yqingyu.httpserver.db.DB;

import java.sql.*;

/**
 * @author YYJ
 * @version 1.0.0
 * @ClassName top.yqingyu.httpserver.controller.Controller
 * @description
 * @createTime 2022年10月26日 23:26:00
 */
@QyController
public class Controller {

    @QyController(path = "value", method = HttpMethod.GET)
    public String getDbTest() throws SQLException {
        Connection connection = DB.getConnection();
        PreparedStatement pst = connection.prepareStatement("SELECT 1 from dual");
        pst.execute();
        ResultSet resultSet = pst.getResultSet();
        resultSet.next();
        String string = resultSet.getString(1);
        resultSet.close();
        pst.close();
        connection.close();
        return string;
    }
}
